package com.invengo.testrfid.app.proxy;

import com.invengo.testrfid.app.proxy.real.RealNetWorkerOkgo;
import com.invengo.testrfid.app.proxy.subject.SubjectNetWork;

public class ProxyNetWorker implements SubjectNetWork {

    private static SubjectNetWork subjectNetWork;
    private static ProxyNetWorker proxyNetWorker;

    public static ProxyNetWorker getInstance() {

        if (proxyNetWorker == null || subjectNetWork == null) {
            subjectNetWork = new RealNetWorkerOkgo();
            proxyNetWorker = new ProxyNetWorker();
        }
        return proxyNetWorker;
    }

    @Override
    public void getServerData(String url, RequestCallback requestCallback) {

        this.subjectNetWork.getServerData(url, requestCallback);
    }

    public interface RequestCallback {

        void onSuccess(String data);

        void onFailed(String msg);
    }
}
